const express = require('express');
const router = express.Router();
const orderController = require('../controllers/orderController');
const { authenticate, authorize } = require('../middleware/auth');

// 顾客路由
router.post('/', authenticate, orderController.createOrder);
router.get('/', authenticate, orderController.getOrders);
router.get('/:id', authenticate, orderController.getOrder);
router.put('/:id/cancel', authenticate, orderController.cancelOrder);
router.put('/:id/pay', authenticate, orderController.payOrder);
router.put('/:id/deliver', authenticate, orderController.deliverOrder);

// 商家路由
router.get('/merchant/orders', authenticate, authorize(['merchant']), orderController.getMerchantOrders);
router.get('/merchant/orders/:id', authenticate, authorize(['merchant']), orderController.getMerchantOrder);
router.put('/merchant/orders/:id/ship', authenticate, authorize(['merchant']), orderController.shipOrder);

module.exports = router;